package gaml.java;

import gaml.java.serializer.ComplexSerializerFactory;
import gaml.java.serializer.EnumSerializerFactory;
import gaml.java.serializer.NullSerializer;
import gaml.java.serializer.ObjectSerializer;
import gaml.java.serializer.collection.ArrayListSerializer;
import gaml.java.serializer.collection.HashMapSerializer;
import gaml.java.serializer.collection.HashSetSerializer;
import gaml.java.serializer.collection.HashtableSerializer;
import gaml.java.serializer.collection.LinkedHashMapSerializer;
import gaml.java.serializer.collection.LinkedHashSetSerializer;
import gaml.java.serializer.collection.LinkedListSerializer;
import gaml.java.serializer.collection.TreeMapSerializer;
import gaml.java.serializer.collection.TreeSetSerializer;
import gaml.java.serializer.collection.VectorSerializer;
import gaml.java.serializer.primitive.BooleanSerializer;
import gaml.java.serializer.primitive.DoubleSerializer;
import gaml.java.serializer.primitive.FloatSerializer;
import gaml.java.serializer.primitive.IntegerSerializer;
import gaml.java.serializer.primitive.LongSerializer;
import gaml.java.serializer.primitive.ShortSerializer;
import gaml.java.serializer.primitive.StringSerializer;


/**
 * create an instance of java class serializer's store
 * with initial set of serializers
 * @author shnireck
 *
 */
public class DefaultSerializerStoreFactory {
	
	/**
	 * a new store with basic set of class serializers
	 * @return new java class serializer's store
	 */
	public static ClassSerializerStore getStore () {
		ClassSerializerStore store = new ClassSerializerStore ();

		store.setComplexFactory (new ComplexSerializerFactory (store));
		store.setEnumFactory (new EnumSerializerFactory ());

		store.setNullSerializer (new NullSerializer ());

		store.register (new ObjectSerializer ());
		store.register (new StringSerializer ());
		store.register (new ShortSerializer ());
		store.register (short.class, store.get (Short.class));
		store.register (new IntegerSerializer ());
		store.register (int.class, store.get (Integer.class));
		store.register (new LongSerializer ());
		store.register (long.class, store.get (Long.class));
		store.register (new FloatSerializer ());
		store.register (float.class, store.get (Float.class));
		store.register (new DoubleSerializer ());
		store.register (double.class, store.get (Double.class));
		store.register (new BooleanSerializer ());
		store.register (boolean.class, store.get (Boolean.class));

		store.register (new VectorSerializer (store));
		store.register (new ArrayListSerializer (store));
		store.register (new LinkedListSerializer (store));
		
		store.register (new HashtableSerializer (store));
		store.register (new HashMapSerializer (store));
		store.register (new TreeMapSerializer (store));
		store.register (new LinkedHashMapSerializer (store));
		
		store.register (new HashSetSerializer (store));
		store.register (new TreeSetSerializer (store));
		store.register (new LinkedHashSetSerializer (store));

		return store;
	}
}
